package com.yulongtian.oneProblemEveryDay.month202301;

/**
 * https://leetcode.cn/problems/first-letter-to-appear-twice/
 * 可
 *
 * @author yulongTian
 * @create 2023-01-01 16:08
 */
public class Test01 {
    public static void main(String[] args) {

    }

    public char repeatedCharacter(String s) {
        int[] chs = new int[26];
        char ans = s.charAt(0);
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (chs[c - 'a'] == 1) {
                ans = c;
                break;
            } else {
                chs[c - 'a']++;
            }
        }
        return ans;
    }
}
